///PHILOTES Source Code.  (C)2012 PhiloLabs
#pragma once

#ifndef _UserObjectsBinding_H__
#define _UserObjectsBinding_H__

#include "OgrePrerequisites.h"
#include "OgreAny.h"

namespace Ogre {


	class _OgreExport UserObjectBindings : public MemAlloc_General
	{
	public:	
		
		UserObjectBindings();

		
		virtual ~UserObjectBindings();

		
		void setUserAny(const Any& anything);

		
		const Any& getUserAny(void) const;

		
		void setUserAny(const String& key, const Any& anything);

		
		const Any& getUserAny(const String& key) const;

		
		void eraseUserAny(const String& key);

		
		void clear() const;

		
		static const Any& getEmptyUserAny() { return msEmptyAny; }

	// Types.
	protected:		
		typedef map<String, Any>::type			UserObjectsMap;
		typedef UserObjectsMap::iterator		UserObjectsMapIterator;
		typedef UserObjectsMap::const_iterator	UserObjectsMapConstIterator;

		
		class Attributes : public MemAlloc_General
		{
		public:
			
			Attributes() : mUserObjectsMap(NULL) {}

			
			~Attributes()
			{
				if (mUserObjectsMap != NULL)
				{
					PHILO_DELETE mUserObjectsMap;
					mUserObjectsMap = NULL;
				}				
			}

			Any					mKeylessAny;		// Will hold key less associated user object for fast access. 	
			UserObjectsMap*		mUserObjectsMap;	// Will hold a map between user keys to user objects.
		};

	// Attributes.
	private:
		static Any				msEmptyAny;			// Shared empty any object.
		mutable Attributes*		mAttributes;		// Class attributes - will be allocated on demand.
		
	};

	
	
}

#endif
